package com.hcy.order_domain.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hcy.ordermodel.dto.request.DriverOrderListRequestDTO;
import com.hcy.ordermodel.dto.request.HomeInfoRequestDTO;
import com.hcy.ordermodel.dto.response.HomeInfoResponseDTO;
import com.hcy.order_domain.entity.ServerOrder;
import com.hcy.order_domain.mapper.ServerOrderMapper;
import com.hcy.order_domain.service.IServerOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hcy.ordermodel.dto.response.OrderInfoResponseDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author hcy
 * @since 2021-12-23
 */
@Service
public class ServerOrderServiceImpl extends ServiceImpl<ServerOrderMapper, ServerOrder> implements IServerOrderService {

    @Autowired
    ServerOrderMapper serverOrderMapper;

    @Override
    public HomeInfoResponseDTO getDriverTodayInfo(HomeInfoRequestDTO requestDTO) {
        return serverOrderMapper.getDriverTodayInfo(requestDTO.getDriverId());
    }

    @Override
    public List<OrderInfoResponseDTO> getDriverRecvOrderInfo(HomeInfoRequestDTO requestDTO) {
        return serverOrderMapper.getDriverRecvOrderInfo(requestDTO.getDriverId());
    }

    @Override
    public List<OrderInfoResponseDTO> getArriveOrderList(DriverOrderListRequestDTO requestDTO) {
        Page<OrderInfoResponseDTO> page = new Page<>();
        page.setCurrent(requestDTO.getPageNO());
        page.setSize(requestDTO.getPageSize());
        Page<OrderInfoResponseDTO> responseDTOPage =  serverOrderMapper.getArriveOrderList(page,requestDTO.getDriverId());
        return responseDTOPage.getRecords();
    }
}
